package com.test.javafaq_faq.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.test.javafaq_commons.entity.Question;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author test.com
* @since 2025-04-11
*/
@Repository
public interface QuestionMapper extends BaseMapper<Question> {

    @Update("update question set status=#{status} where id = #{questionId}")
    Integer updateStatus(Integer questionId,Integer status);

    @Select("SELECT * FROM question q LEFT JOIN user_question uq ON q.id =uq.question_id WHERE uq.user_id = #{id} OR q.user_id = #{id} ORDER BY q.createtime desc")
    List<Question> findTeacherQuestions(Integer id);
}
